/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.webbucks;

import java.sql.*;

/**
 *
 * @author ghaban
 */
public class ManagerBean {
 String username;
 String password;
 /*setters*/
 public void setUsername(String str){
     username = str;
 }
 public void setPassword(String str){
     password = str;
 }
 /*getters*/
 public String getUsername(){
     return username;
 }
 
 /*Computing methods here*/
 public boolean isValid(){
            String url = "jdbc:mysql://localhost:8889/";
        String dbName = "webbucks";
        String driver = "com.mysql.jdbc.Driver";
        String user = "root"; 
        String pw = "root";
        PreparedStatement ps;
        boolean auth = false;
        try {
            Class.forName(driver).newInstance();
            Connection con=DriverManager.getConnection(url+dbName,user,pw);
            String Query = "Select * from manager where username =\""+username+"\" and password=\"" + password+"\"";
            Statement stmt = con.createStatement();
            ResultSet srs = stmt.executeQuery(Query);
            if(srs.next()){
                auth = true;
            }
            con.close();
        }
        catch( Exception e ){
            System.out.println("Something went wrong" + e.toString() );
        }
     return auth;
 }
}
